Requirements:Converts the time of the int type displayed on the first page to the time format of the date type:when Questionmodel gets to question list data, including question[' Pub_time '), it needs to be converted to a specific time format for
JavaScript gets the current timestamp: The first method: var timestamp = date.parse (new date ()); results: 1280977330000 the second method: var timestamp = (new date ()). ValueOf (); results: 1280977330748 The third method: Var timestamp=new Date ()
Time stamps and time-date conversions are common operations, and here are examples of how to implement the conversion between them through a code instance.
Before you learn this article, let's introduce the date () constructor parameters in
JS obtains time-related functions and converts timestamp to time and date. js obtains
Timestamp and date conversion are common operations. The following describes how to implement mutual conversion through code examples.
Before learning this article,
1 //Gets the current timestamp (in s)2 vartimestamp = Date.parse (NewDate ());3timestamp = timestamp/1000;4Console.log ("Current timestamp is:" +timestamp);5 6 7 8 //gets the timestamp of a time format9 varStringTime = "2017-12-06 21:51:12";Ten
One: Time-to-timestamp: JavaScript obtains timestamps in four ways, all by instantiating the time object new Date () to further obtain the current timestamp1.var TIMESTAMP1 = date.parse (New Date ()); Results: 1477808630000 This method is not
The time stamp in PHP is compared to the timestamp in JavaScript, in essence, they are the same thing, but if the two want to make an equal comparison, or a little different, a little attention, will go astray, so, here list easily overlooked two
In the study of Liaoche predecessors of the JavaScript tutorial, encountered some points needing attention, so as a study notes listed, remind yourself to notice!If you have the need, welcome to visit the previous blog https://www.liaoxuefeng.com/
One: Time-to-timestamp: JavaScript obtains timestamps in four ways, all by instantiating the time object new Date () to further obtain the current timestamp1.var TIMESTAMP1 = date.parse (New Date ()); Results: 1477808630000 This method is not
2016-08-03 11:41:10New Date ()New Date (milliseconds)New Date (datestring)New Date (year, month)New Date (year, month, day)New Date (year, month, day, hours)New Date (year, month, day, hours, minutes)New Date (year, month, day, hours, minutes,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.